package com.dubbo.customer;

import javax.annotation.Resource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.dubbo.customer.config.DubboConfig;

@Configuration
public class AppBeanFactory {

	@Resource
	private DubboConfig dubboConfig;

	/**
	 * dubbo应用配置
	 * 
	 * @return
	 */
	@Bean
	public ApplicationConfig applicationConfig() {
		ApplicationConfig c = new ApplicationConfig();
		c.setName(dubboConfig.getApplicationName());
		c.setOwner(dubboConfig.getApplicationOwner());
		c.setVersion(dubboConfig.getApplicationVersion());
		return c;
	}

	/**
	 * 注册中心配置
	 * 
	 * @return
	 */
	@Bean
	public RegistryConfig registryConfig() {
		RegistryConfig c = new RegistryConfig();
		c.setAddress(dubboConfig.getRegistryAddress());
		c.setFile(dubboConfig.getRegistryFile());
		return c;
	}

}
